package com.demo.my_util.table_md;

import com.jfinal.plugin.activerecord.generator.MetaBuilder;

import javax.sql.DataSource;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.regex.Pattern;

/**
 * 针对OAIS数据库的表映射生成策略
 *
 * @author dengguoqi
 */
public class DM_MetaBuilder extends MetaBuilder {

    public DM_MetaBuilder(DataSource dataSource) {
        super(dataSource);
    }

    @Override
    protected boolean isSkipTable(String tableName) {
        return !tableName.toUpperCase().startsWith("AS_") || Pattern.compile("[0-9]").matcher(tableName).find();
    }

    public static void main(String[] args) {
        String tableName = "AS_288_REC";
        System.err.println(Pattern.compile("[0-9]").matcher(tableName).find());
    }

    @Override
    protected ResultSet getTablesResultSet() throws SQLException {
        return dbMeta.getTables(conn.getCatalog(), null, "%", new String[]{"TABLE"});
    }
}
